<legend>投票页</legend>
<?php
$model = new BDynamicFormModel();
$questionField = 'question';

$pollTable = new BWWePollSheet('WePoll');
$poll = $pollTable->getListById($pollId);

$pollItemTable = new BWWePollSheet('WePollItem', $poll);
$pollItemView = $pollItemTable->getView();

$form = $this->beginWidget('CActiveForm', array(
    "id" => "pollForm",
    'enableAjaxValidation' => FALSE,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
        ));
?>
<form role="form">
    <div class="form-group">
        <?php
        foreach ($pollItemView as $itemId => $pollItem) {
            $pollValueTable = new BWWePollSheet('WePollValue', $pollItem);
            //get current user
            $myPollValue = $pollValueTable->getList(array('userId' => Blyn::app()->getCurrentUser()->getId()));

            $question = $pollItem->getItem('question')->getValue();
            $model->$questionField = $question;

            CHtml::activeLabel($model, $questionField);
            $optionField = 'media_value_pollItem_' . $itemId;

            $options = array();
            for ($index = 1; $index < 100; $index++) {
                $optionName = 'option' . $index;
                $optionItem = $pollItem->getItem($optionName);
                if ($optionItem) {
                    $option = $optionItem->getValue();
                    
                    $model->$optionField = $option;
                    $options[$index] = $optionItem->getValue();
                } else {
                    break;
                }
                CHtml::activeRadioButtonList($model, $optionField, $options);
            }
        }
        ?>
    </div>
</form>
<?php
$this->endWidget();
?>

